package com.hspedu.newData.dmsxl.数学技巧;

import org.junit.Test;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-27 
 * @Version: 1.0
 */

public class LC2894分类求和并做差 {

    public int differenceOfSums(int n, int m) {

        int sum = 0;
        int x = m;
        while (n>=m){
            sum+=m;
            m+=x;
        }

        return n*(n+1)/2 - 2*sum;

    }

    @Test
    public void test() {
        // 测试代码
        differenceOfSums(5,1);
        differenceOfSums(10,3);
        differenceOfSums(10,3);
        differenceOfSums(10,3);
    }

}
